   
      ***data paths 
  
   global posted /Volumes/Sans titre/DATA_MICROEU/Posting
   global data /Users/Mathilde/Dropbox/Posted_workers/Data
   
   
   
   **output paths
  global replication_outputs_a /Users/Mathilde/Dropbox/Posted_workers/Replication/TNT_final/Replication_package/Appendix_figures
  global replication_estimates /Users/Mathilde/Dropbox/Posted_workers/Replication/TNT_final/Replication_package/Main_estimates
  global replication_estimates_a /Users/Mathilde/Dropbox/Posted_workers/Replication/TNT_final/Replication_package/Appendix_estimates
  global replication_outputs /Users/Mathilde/Dropbox/Posted_workers/Replication/TNT_final/Replication_package/Main_figures
   
   
   *************Employment series from ILO (BIH- Employment by sex and economic activity, can be downloaded in ILO website)
   
   use "$data/Employment_Eurostat/ilostat-2020-11-30.dta", clear
   g sector="."
   replace sector="agriculture" if classif1_label=="Economic activity (Detailed): Agriculture; forestry and fishing ~ISIC rev.4 A"
   replace sector="health" if classif1_label=="Economic activity (Detailed): Human health and social work activities ~ISIC rev.4 Q"
   replace sector="construction" if classif1_label=="Economic activity (Aggregate): Construction"
   replace sector="public" if classif1_label=="Economic activity (Aggregate): Public Administration, Community, Social and other Services and Activities"
   replace sector="education" if classif1_label=="Economic activity (Detailed): Education ~ISIC rev.4 P"
   replace sector="admin" if classif1_label=="Economic activity (Detailed): Real estate; business and administrative activities ~ISIC rev.4 L; M; N"
   replace sector="total" if classif1_label=="Economic activity (Detailed): Total"

   rename ref_area_label country
   rename time year
   destring year, replace 
   keep if sex_label=="Sex: Total"
   
   g tot_d=obs_value if sector=="total"
   egen tot=min(tot_d), by(country year)
   
   
   g share=obs_value/tot
   
   
   twoway (connected obs_value year if sector=="construction" & year>1999 & country=="Poland", lcolor(cranberry) mcolor(cranberry)) ///
   (connected obs_value year if sector=="health" & year>1999 & country=="Poland", lcolor(dknavy) mcolor(dknavy)) ///
   , graphregion(fcolor(white) lcolor(white)) ///
   legend(label(1 "Construction") label(2 "Health") cols(1) ring(0) pos(5)) /// 
   xline(2004, lcolor(red)) ylabel(0 (500) 2000) /// 
   ytitle("Employment (Thousands)") xtitle("") xlabel(2000 (1) 2020, angle(vertical))
   graph export "$replication_outputs_a/FigureE74.pdf", replace


   
   
   
    twoway (connected obs_value year if sector=="construction" & year>1999 & country=="Ukraine", lcolor(cranberry) mcolor(cranberry)) ///
   (connected obs_value year if sector=="health" & year>1999 & country=="Ukraine", lcolor(dknavy) mcolor(dknavy)) ///
   , graphregion(fcolor(white) lcolor(white)) ///
   legend(label(1 "Construction") label(2 "Health") cols(1) ring(0) pos(5)) /// 
   xline(2004, lcolor(red)) ylabel(0 (500) 2000) /// 
   ytitle("Employment (Thousands)") xtitle("") xlabel(2000 (1) 2020, angle(vertical))
   graph export "$replication_outputs_a/FigureE74b.pdf", replace
   
   
   
   *******************Truck driver example using Eurostat data on truck driving performance*******
   *Data to export fron Eurostat website ROAD_GO_TA_TOTT
   *********************************************************
   
    
  
 
 import excel "$data/transport/tkm.xlsx", sheet("total") firstrow clear
 destring n*, replace force
 reshape long n, i(TIME) j(year)
 rename n total 
 save "$data/transport/totaltkt.dta", replace
 
 
 import excel "$data/transport/tkm.xlsx", sheet("foreign") firstrow clear
 destring n*, replace force
 reshape long n, i(TIME) j(year)
 rename n foreign
 save "$data/transport/foreigntkt.dta", replace
 
 merge 1:1 year TIME using "$data/transport/totaltkt.dta"
 
 rename TIME country
 
 sort year
 twoway (connected total year if country=="Pologne") ///
 (connected total year if country=="France") ///
  (connected total year if country=="Allemagne")
  
  
  
   twoway (connected foreign year if country=="Pologne") ///
 (connected foreign year if country=="France") ///
  (connected foreign year if country=="Allemagne")
  
  
  foreach y in total foreign{
  g normi`y'=`y' if year==2003
  egen nordm`y'=min(normi`y'), by(country)
  g `y'_n=`y'/nordm`y'
  
  g normi2`y'=`y' if year==2004
  egen nordm2`y'=min(normi2`y'), by(country)
  g `y'_n2=`y'/nordm2`y'
  
  
  replace `y'_n=`y'_n2 if missing(`y'_n)
  }
  drop if year>2017
  
    twoway (connected foreign_n year if country=="Pologne", lcolor(cranberry) mcolor(cranberry)) ///
 (connected foreign_n year if country=="France", lcolor(gs10) mcolor(gs10)) ///
  (connected foreign_n year if country=="Belgique", lcolor(gs10) mcolor(gs10) msymbol(t) lpattern(dash)) ///
   (connected foreign_n year if country=="Slovénie", lcolor(cranberry) mcolor(cranberry) lpattern(dash))  ///
    (connected foreign_n year if country=="Slovaquie", lcolor(cranberry) mcolor(cranberry) msymbol(X) ) ///
  (connected foreign_n year if country=="Estonie", lcolor(cranberry) mcolor(cranberry) msymbol(T) lpattern(dash)) ///
   (connected foreign_n year if country=="Hongrie", lcolor(cranberry) mcolor(cranberry) lpattern(dash) msymbol(X)) ///
   (connected foreign_n year if country=="Autriche", lcolor(gs10) mcolor(gs10) lpattern(dash) msymbol(s)), ///
  legend(label(1 "Poland") label(2 "France") label(3 "Belgium") label(4 "Slovenia") ///
  label(5 "Slovakia") label(6 "Estonia") label(7 "Hungary") label(8 "Austria") order(1 4 5 6 7 2 3 8) ) ///
  graphregion(fcolor(white) lcolor(white)) xline(2003.5, lcolor(red)) xtitle("") ///
  ytitle("Road Freight Transport Abroad (2003=1)") 
  	graph export "$replication_outputs_a/FigureE75a.pdf", replace

  
  twoway (connected total_n year if country=="Pologne", lcolor(cranberry) mcolor(cranberry)) ///
 (connected total_n year if country=="France", lcolor(gs10) mcolor(gs10)) ///
  (connected total_n year if country=="Belgique", lcolor(gs10) mcolor(gs10) msymbol(t) lpattern(dash)) ///
   (connected total_n year if country=="Slovénie", lcolor(cranberry) mcolor(cranberry) lpattern(dash))  ///
    (connected total_n year if country=="Slovaquie", lcolor(cranberry) mcolor(cranberry) msymbol(X) ) ///
  (connected total_n year if country=="Estonie", lcolor(cranberry) mcolor(cranberry) msymbol(T) lpattern(dash)) ///
   (connected total_n year if country=="Hongrie", lcolor(cranberry) mcolor(cranberry) lpattern(dash) msymbol(X)) ///
   (connected total_n year if country=="Autriche", lcolor(gs10) mcolor(gs10) lpattern(dash) msymbol(s)), ///
  legend(label(1 "Poland") label(2 "France") label(3 "Belgium") label(4 "Slovenia") ///
  label(5 "Slovakia") label(6 "Estonia") label(7 "Hungary") label(8 "Austria") order(1 4 5 6 7 2 3 8) ) ///
  graphregion(fcolor(white) lcolor(white)) xline(2003.5, lcolor(red)) xtitle("") ///
  ytitle("Total Road Freight Transport (2003=1)") 
  	graph export "$replication_outputs_a/FigureE75b.pdf", replace

  
   twoway (connected total_n year if country=="east", lcolor(cranberry) mcolor(cranberry)) ///
 (connected total_n year if country=="west", lcolor(gs10) mcolor(gs10)) ///
 (connected total_n year if country=="total", lcolor(blue) mcolor(blue)) , ///
  legend(label(1 "New Member States of 2004") label(2 "Western Europe")  label(3 "Total EU") cols(1) ring(0) pos(11)) ///
  graphregion(fcolor(white) lcolor(white)) xline(2004, lcolor(red)) xtitle("") ///
  ytitle("Road Freight Transport (2004=1)") 

  
   twoway (connected total year if country=="east", lcolor(cranberry) mcolor(cranberry)) ///
 (connected total year if country=="west", lcolor(gs10) mcolor(gs10)) ///
 (connected total year if country=="total", lcolor(blue) mcolor(blue)) , ///
  legend(label(1 "New Member States of 2004") label(2 "Western Europe")  label(3 "Total EU") cols(1) ) ///
  graphregion(fcolor(white) lcolor(white)) xline(2004, lcolor(red)) xtitle("") ///
  ytitle("Road Freight Transport (2004=1)") 

  
  
  
  
  
  
  
  
  

  
  
 

   
   
